<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" />
    <title>安平通行码</title>
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
    <style>
        * {
            background: #F2F6FB;
        }

        .layui-text {
            background: #D7E8FF;
            line-height: 16px;
            color: #265DA4;
            font-weight: bolder;
            font-size: 16px;
        }

        .layui-input,
        .layui-textarea {
            width: 95%;
            background: #E9F1FB;
            border-color: #E9F1FB;
            border-radius: 4px;
            box-shadow: 0 0 14px 0 rgba(0, 0, 0, 0.2);
        }

        .layui-form-item .layui-form-label {
            text-overflow: clip;
        }

        .footer {
            text-align: center;
            font-size: 12px;
            color: #666666;
            position: fixed;
            bottom: 0;
            width: 100%;
        }

        .footer p {
            margin: 5px 0;
        }

        .layui-elem-quote {
            text-align: center;
            border-left: none;
        }

        .layui-form-radio>i:hover,
        .layui-form-radioed>i {
            color: #275DA4;
        }


        .layui-btn {
            background-color: #275DA4;
            box-shadow: 0 0 14px 0 rgba(0, 0, 0, 0.2);
        }

        .tishi {
            text-align: center;
            color: #666;
            font-size: 14px;
            margin-top: 10px;
            margin-bottom: 10px;
        }

        .layui-form-label {
            padding: 9px 9px 9px 0;
        }

        .layui-input-block {
            margin-left: 91px;
        }

        #launch-btn {
            width: 240px;
            padding-left: 60px;
            background: #fff;
        }

        .b {
            background-color: #cbcbcb;
        }

        .htmls {
            min-height: 480px;
        }

        textarea {
            border: 1px solid #E9F1FB;
            resize: none;
            background: #E9F1FB;
            box-shadow: 0 0 14px 0 rgba(0, 0, 0, 0.2);
        }

        .all {
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            background: rgba(0, 0, 0, 0.4);
            display: none;
        }

        .tankuang {
            background: #fff;
            width: 300px;
            height: 290px;
            position: fixed;
            top: 50%;
            margin-top: -150px;
            left: 50%;
            margin-left: -150px;
            border-radius: 10px;
            padding-top: 10px;
        }

        .tankuang .one_btn {
            width: 200px;
            margin-left: 50px;
            background: #fff;
            margin-bottom: 30px;
            margin-top: 30px;
        }
    </style>

</head>

<body>
    <blockquote class="layui-elem-quote layui-text">
        安平通行码登记
    </blockquote>
    <form class="layui-form" action="">
        <div class="htmls">
            <input type="hidden" name="changsuoId" class="_changsuoId">
            <input type="hidden" name="openId" class="_openid">
            <div style="text-align: center;height: 40px;line-height: 30px;">
                <div style="font-weight: bolder;font-size: 16px;color: #999;" class="title_"></div>
            </div>
            <div style="text-align: center;height: 40px;line-height: 30px;">
                <div style="font-weight: bolder;font-size: 14px;color: rgb(146, 9, 9);" class="people_"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">体温*</label>
                <div class="layui-input-block">
                    <input type="number" name="temperature" lay-verify="number" lay-reqtext="请输入今日体温"
                        placeholder="请输入今日体温" autocomplete="off" class="layui-input" maxlength="4">
                </div>
            </div>

            <div class="layui-form-item" style="text-align: center;">
                <button type="submit" class="layui-btn layui-date" lay-submit="" lay-filter="demo1"
                    style="width: 200px;"></button>
            </div>
        </div>
        <img src="http://hesuan.city1000.cn/images/tishi.png" alt="" width="90%"
            style="margin-left: 4%;margin-top: 20px;">
        <div class="tishi">技术支持: 智慧安平</div>
        <!-- 弹框 -->
        <div class="all">
            <div class="tankuang">
                <img src="http://hesuan.city1000.cn/codesure/images/code.png?v=02" alt="" class="one_btn">
                <wx-open-launch-weapp id="launch-btn" username="gh_21c954017d6d">
                    <template>
                        <style>
                            .two_btn {
                                width: 180px;
                                height: 40px;
                                background: #275DA4;
                                line-height: 40px;
                                text-align: center;
                                color: #fff
                            }
                        </style>
                        <!-- 路径必须是绝对路径 -->
                        <div class="two_btn">打开健康码</div>
                    </template>
                </wx-open-launch-weapp>
            </div>
        </div>
    </form>
    <script src="../layui/layui.js" charset="utf-8"></script>
    <script src="../jquery/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/fastclick/1.0.6/fastclick.min.js"></script>
    <script src="../api/api.js?v=01"></script>
    <script>
        setInterval(time, 60000)

        function time() {
            var date = new Date()
            var year = date.getFullYear()
            var month = date.getMonth() + 1
            var day = date.getDate()
            var hour = date.getHours()
            var minute = date.getMinutes()
            if (hour < 10) {
                hour = "0" + hour
            }
            if (minute < 10) {
                minute = "0" + minute
            }
            console.log(year, month, day)
            $(".layui-date").html(year + '-' + month + '-' + day + " " + hour + ":" + minute + '  登记')
        }
        time()
        layui.use(['form', 'layer', 'jquery'], function () {
            var form = layui.form,
                layer = layui.layer,
                $ = layui.jquery;
            var order_data = getQueryVariable('state')
            // openid 和 rukouId 和  和中文的入口地址和姓名
            $("._changsuoId").val(Number(order_data.split('+')[1]))
            $(".title_").html(order_data.split('+')[2])
            $(".people_").html(order_data.split('+')[3])
            $("._openid").val(order_data.split('+')[0])
            $(document).ready(function () {
                // 防止按钮延迟
                FastClick.attach(document.body);
            })
            //监听提交
            form.on('submit(demo1)', function (data) {
                console.log(data)
                var loadIndex;
                $.post(ymt_api + "/ymtUserChaoshi/save", data.field, function (
                    res) {
                    console.log(res)
                    if (res.code == 0) {
                        document.body.scrollTop = 0;
                        document.documentElement.scrollTop = 0;
                        document.body.style.height = "100%"
                        document.body.style.overflow = "hidden"
                        $(".all").css("display", "block")
                        console.log("已经注册过页面路径" + window.location.href)
                        $.ajax({
                            type: "get",
                            url: "http://user.city1000.top/wechat/wxScan", //自己填写请求地址
                            data: {
                                url: window.location.href
                            },
                            success: function (res) {
                                //console.log(result)
                                wx.config({
                                    // 开启调试模式,调用的所有api的返回值会在客户端//alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                                    debug: false,
                                    appId: res.appId,
                                    timestamp: res.timestamp,
                                    nonceStr: res.nonceStr,
                                    signature: res.signature,
                                    jsApiList: ['checkJsApi'],
                                    openTagList: [
                                        'wx-open-launch-weapp'
                                    ] //这里直接添加，什么都不用管
                                });
                                wx.error(function (res) {
                                    alert("出错了：" + res
                                        .errMsg
                                    ); //这个地方的好处就是wx.config配置错误，会弹出窗口哪里错误，然后根据微信文档查询即可。
                                });
                                var btn = document
                                    .getElementById(
                                        'launch-btn');
                                btn.addEventListener('launch',
                                    function (e) {});
                                btn.addEventListener('error',
                                    function (e) {});
                            }
                        })
                    }
                })
                return false;
            })
        })

        function getQueryVariable(variable) {
            var query = decodeURI(window.location.search.substring(1))
            var vars = query.split("&");
            for (var i = 0; i < vars.length; i++) {
                var pair = vars[i].split("=");
                if (pair[0] == variable) {
                    return pair[1];
                }
            }
            return (false);
        }
    </script>
</body>

</html>